package mvc.controllers.app
{
	import flash.display.Bitmap;
	
	import globals.Global;
	
	import mvc.Notifications;
	import mvc.models.proxys.AppMainProxy;
	import mvc.views.AppMainView;
	import mvc.views.mediators.AppViewMediator;
	import mvc.views.mediators.MediatorAccessListFrame;
	import mvc.views.mediators.MediatorBackgroundLayer;
	import mvc.views.mediators.MediatorLoginFrame;
	import mvc.views.mediators.MediatorMainFrame;
	import mvc.views.mediators.MediatorSwfAddress;
	import mvc.views.mediators.MediatorUILayer;
	
	import org.osmf.logging.Log;
	import org.puremvc.as3.interfaces.INotification;
	import org.puremvc.as3.patterns.command.SimpleCommand;
	import org.puremvc.as3.patterns.mediator.Mediator;
	
	import xl.utils.Tracker;
	import xl.utils.UtilsGraphics;
	
	public class StartOverCommand extends SimpleCommand
	{
		public function StartOverCommand()
		{
			super();
		}
		
		override public function execute(notification:INotification):void
		{
			// TODO Auto Generated method stub
			super.execute(notification);
			
			var appEditor:SRWeb = notification.getBody()["app"] as SRWeb;
			var appView:AppMainView = notification.getBody()["appView"] as AppMainView;
			appEditor.addChild(appView);
			Tracker.log("start up over");
			
			Global.uiLayer = appView.uiLayer;
			
			//注册代理（Proxy）
			facade.registerProxy(new AppMainProxy());
			
			//注册Mediator UI组件的中介器
			facade.registerMediator(new AppViewMediator(AppViewMediator.NAME,appView));
			facade.registerMediator(new MediatorSwfAddress(MediatorSwfAddress.NAME));
			facade.registerMediator(new MediatorBackgroundLayer(MediatorBackgroundLayer.NAME,appView.backgroundLayer));
			facade.registerMediator(new MediatorUILayer(MediatorUILayer.NAME,appView.uiLayer));
			
			facade.registerMediator(new MediatorLoginFrame(MediatorLoginFrame.NAME));
			facade.registerMediator(new MediatorAccessListFrame(MediatorAccessListFrame.NAME));
			facade.registerMediator(new MediatorMainFrame(MediatorMainFrame.NAME));
			
			
			
			
			//加载配置文件
			(facade.retrieveProxy(AppMainProxy.NAME) as AppMainProxy).loadConfig();
			sendNotification(Notifications.MEDIATOR_APP_TO_SHOW);
		}
		
	}
}